// pages/login/login.js
Page({
  data: {
    codeContext:"获取验证码",
    currentTime:3,
  },
  getCode(){
    let that=this
    let currentTime = this.data.currentTime
    let codeContext=this.data.codeContext
    let phone=this.data.phone
    if(phone != "" && phone.length == 11){
      if(codeContext == "获取验证码"){
      let time = setInterval(()=>{
      if(currentTime>0){
        currentTime--
        that.setData({
          codeContext:"重新发送"+"("+currentTime+"s)"
        })
      }else{
        clearInterval(time)
        that.setData({
          codeContext:"获取验证码"
        })
      }
    },1000)
    }
    }else{
      wx.showToast({
        title: '手机号码不正确',
        icon:"none",
        duration:2000
      })
    }
  },
  inputPhone(e){
    console.log(e)
    this.setData({
      phone:e.detail.value
    })
  },
  toLogin(){
    wx.setStorage({
      key:"userinfo",
      data:{
        bg: "https://sns-video-hw.xhscdn.com/stream/110/259/01e54227b1aa9068010377038b8a6c688b_259.mp4",
        headUrl: "/image/sucai/c9ac2f1c-230d-4c80-ba00-401f6c66d92d.png",
        userName: "Rise",
        code: "10086",
        IP_address: "",
        detail: "18岁男大",
        sex: 1,
        taglist: ["爱吃辣", "爱睡觉"]
      }
    })
    wx.switchTab({
      url: '/pages/me/me',
    })
  }
})